#include <iostream>
#include <queue>

//#include "reopen.h"

using namespace std;

class tree{
public:
	int first;
	int second;
};

bool operator<(tree a,tree b){
	return a.second>b.second;
}
int main(void){
	reopen("P1478_3");

	int n,s,a,b,tmp1,total=0;
	cin>>n>>s>>a>>b;
	priority_queue<tree> m;
	for(int i=0;i<n;i++){
		tree temp;
		cin>>temp.first>>temp.second;
		if(temp.first>a+b)continue;
		m.push(temp);
//		cout<<"push "<<temp.first<<" "<<temp.second<<endl;
	}
//	cout<<m.size()<<endl;
	for(;s>0;){
		if(m.empty())break;
		tmp1=m.top().second;
//			cout<<tmp1<<endl;
		m.pop();
		if(s>=tmp1){
			s-=tmp1;
			total++;
//			cout<<"s:"<<s<<",tmp:"<<tmp1<<endl;
		}else{
			break;
		}

	}
	cout<<total;
	return 0;
}

